<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>3542：DZY Loves March</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">DZY Loves March</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">DZY Loves March</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                DZY Loves March                </h1>
                <p>时间限制：10s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：256MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><div>
<div><span style="font-size: medium">在一片m*m的地上．驻扎着n个军队,编号依次为1~n,第i个军队的位置可用二元组(xi,yi)表示，可能有多个军队驻扎在同一个位置。</span></div>
<div><span style="font-size: medium">接下来有t个时刻，每个时刻会发生下列两种事件之一：</span></div>
<div><span style="font-size: medium">(1)第x个军队向一个方向（向上(U)向下(D)向左(L)向右(R)）移动了d个单位：</span></div>
<div><span style="font-size: medium">(2)第x个军队需要集结和它在同一行或同一列的且编号在[l,r]的军队，也就是说，这些军队需要赶到第x个军队的驻地。</span></div>
<div><span style="font-size: medium">定义第i个军队赶到第j个军队所需的花费为cost(i,j)=(xi-xj)^2+(yi-yj)^2</span></div>
<div><span style="font-size: medium">请你输出每次集结时，所有被集结的军队的花费之和，对10^9+7取模。</span></div>
</div></p><hr/><h3>输入格式</h3><p><p><font size="4">&nbsp; 第一行，两个数n和M。<br />
&nbsp; 描下来r一行，每行两个数xi,yi<br />
&nbsp; 下一行，一个数t。<br />
&nbsp; 描下来t行，每行的格式为下列两种格式之一<br />
&nbsp; (l)S x d,其中S&isin;{U,L,D,R}，代表第一种事：<br />
&nbsp; (2)Q x L R，代表第二种事件。<br />
&nbsp; 为了体现在线询问,每次你读进x'后，真正的x=x' xor lastans,其中lastans是上一次答案对10^9+7取模后的结果，一开始lastans=0</font></p></p><hr/><h3>输出格式</h3><p><p><span style="font-size: medium"><br />
对于每一个Q事件，输出一个答案，对10^9+7取模</span></p></p><hr/><h3>样例输入</h3><pre>【样例输入】
5 3
1 2
2 2
3 2
2 1
2 3
7
Q 2 1 5
Q 6 3 4
D 1 1
Q 0 1 5
Q 7 1 5
L 5 1
Q 4 1 5
</pre><hr/><h3>样例输出</h3><pre>4
2
3
6
4
【样例解释】
解密后的输入：
Q 2 1 5
Q 2 3 4
D 3 1
Q 2 1 5
Q 4 1 5
L 3 1
Q 2 1 5
</pre><hr/><h3>提示</h3><p><p><img alt="" width="637" height="168" src="../file/3542_0.jpg" /></p>
<p><span style="font-size: medium">样例还看不懂就看下图</span></p>
<p><span style="font-size: medium"><br />
</span><span style="font-size: medium">【数据范围】<br />
n&le;100000，m&le;10^18。保证军队在移动过程中不会超出边界。<br />
每个军队集结后会回到原来的驻地</span></p></p><hr/><h3>题目来源</h3><p>By Dzy</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=3542" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=3542" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>